import path from 'path'
import { defineConfig } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

export default defineConfig({
  main: {
    resolve: {
      alias: {
        '~': path.resolve('.'),
        '@app': path.resolve('./src/app')
      }
    },
    build: {
      outDir: path.resolve('./out/app'),
      sourcemap: true,
      lib: {
        entry: path.resolve('./src/app/main.ts')
      }
    }
  },
  preload: {
    publicDir: false,
    resolve: {
      alias: {
        '~': path.resolve('.'),
        '@middleware': path.resolve('./src/middleware')
      }
    },
    build: {
      sourcemap: true,
      outDir: path.resolve('./out/middleware'),
      lib: {
        entry: path.resolve('./src/middleware/main.ts')
      }
    }
  },
  renderer: {
    server: {
      host: '0.0.0.0',
      port: 9527,
      strictPort: true
    },
    resolve: {
      alias: {
        '~': path.resolve('.'),
        '@render': path.resolve('./src/render')
      }
    },
    plugins: [vue(), vueJsx()],
    root: path.resolve('.'),
    build: {
      rollupOptions: {
        input: path.resolve('./index.html')
      }
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: '@import "./src/render/styles/_variable.scss"; @import "./src/render/styles/_theme.scss";'
        }
      }
    }
  }
})
